<template>
  <div class="page-view">
    <div
      v-if="header"
      class="page-header"
    >
      <breadcrumb class="breadcrumb-container" />
      <div
        v-show="showTitle"
        class="page-title"
      >
        {{ title }}
      </div>
      <div class="page-desc">
        <slot name="page-desc" />
      </div>
    </div>
    <div
      v-if="showSearch"
      class="page-search"
    >
      <slot name="page-search" />
    </div>
    <div
      class="page-body"
      :class="{blank: isBlank}"
    >
      <slot name="default" />
    </div>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb';
/**
 * 通用页面
 * @author maolin
 */
export default {
  name: 'PageView',
  components: {
    Breadcrumb
  },
  props: {
    /**
     * 页面标题
     * @public
     */
    title: {
      type: String,
      default () {
        return this.$route.meta.title || '';
      }
    },
    /**
     * 页面描述显示
     * @public
     */
    desc: {
      type: String,
      default: ''
    },
    /**
     * 是否显示头部
     * @public
     */
    header: {
      type: Boolean,
      default: true
    },
    /**
     * 是否显示头部标题
     * @public
     */
    showTitle: {
      type: Boolean,
      default: true
    },
    /**
     * 是否显示搜索框
     * @public
     */
    showSearch: {
      type: Boolean,
      default: false
    },
    /**
     * 是否白底
     * @public
     */
    isBlank: {
      type: Boolean,
      default: true
    }
  }
};
</script>

<style scoped lang="scss">
  .page-view{
    .page-header{
      background-color: #fff;
      padding: 20px;
      font-size: 14px;
      color: rgba(0,0,0,0.45);
      .page-title{
        font-size: 20px;
        line-height: 32px;
        color: rgba(0,0,0,.85);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-weight: 600;
        margin-bottom: 10px;
      }
    }
    .page-search{
      margin-top: 20px;
      background-color: #fff;
      padding: 20px;
    }
    .page-body{
      margin-top: 20px;
      background: none;
      &.blank{
        background-color: #fff;
        padding: 40px 20px;
      }
    }
  }
</style>
